home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 008a / feb93cad.zip / XINT.LSP < prev   
Lisp/Scheme  |  1993-02-12  |  4KB  |  101 lines

  1. ; XINT.LSP
  2. ; Intersection of Lines/Arcs/Circles Snap Program  
  3. ; Selects two entities (lines, arcs, or circles) 
  4. ; and returns a point of intersection.  
  5. ; If NF=0 
  6. ; the near point is returned.  
  7. ; If NF=1 
  8. ; the far point is returned.  
  9. ; The point of intersection is found even if the 
  10. ; intersection is off the screen.  If the entities will 
  11. ; intersect only if they are extended, the theoretical 
  12. ; extended intersection will be returned.
  13. ; Version: 1.1
  14. ; Author: Glenn S. Lyford 5/20/90
  15. ; Revised: George E. Zinsmeister 10/20/90
  16. ;==============================================
  17. ; Parameters
  18. ; Name               Definition
  19. ;----------------------------------------------
  20. ; NF         : flag to indicate whether near or far 
  21. ;              intersection is desired.
  22. ;              N=0 near point is returned.
  23. ;              N=1 far point is returned.
  24. ; ---------------------------------------------
  25. ; Local Variables
  26. ; Variable name      Definition
  27. ; ---------------------------------------------
  28. ; A1, A2, AL : angles, see documentation figures
  29. ; C1, C2     : center points of selected entities
  30. ; D          : distance from center to closest point of a
  31. ;              line
  32. ; DC         : distance from first end point of a line
  33. ;              to center
  34. ; DP         : distance to desired point from PP
  35. ; DR         : sum of radii R1 and R2
  36. ; E1, E2     : list returned by entsel for first and 
  37. ;              second entities selected
  38. ; EL         : utility variable for swapping variables
  39. ; EL1, EL2   : association lists for first and second
  40. ;              entities selected
  41. ; ET         : utility variable for swapping variables
  42. ; ET1, ET2   : type (i.e. line, arc, circle) of first 
  43. ;              and second entities selected
  44. ; P          : returned intersection point; nil is 
  45. ;              returned if there is no intersection point
  46. ; P1, P2     : intersection points when there are two
  47. ;              intersection points
  48. ; PL1, PL2   : end points of a line
  49. ; PP         : closest point of a line
  50. ; PNEAR,PFAR : near/far intersection points
  51. ; PS1        : point where first entity is selected
  52. ; R          : utility variable for swapping variables
  53. ; R1, R2     : radii of selected entities
  54. ; S          : (/ (+ R1 R2 DC) 2), see documentation figures
  55. ;-----------------------------------------------
  56. ;
  57. (defun XINT (NF / A1 A2 AL C1 C2 D DC DP DR E1 E2 EL
  58.              EL1 EL2 ET ET1 ET2 P P1 P2 PL1 PL2 PP 
  59.              PS1 R R1 R2 S)
  60.   (setq  E1 (entsel "intersection of\n"))
  61.   (if E1
  62.     (progn
  63.       (setq E2 (entsel "and\n"))  ; select first entity
  64.       (if E2
  65.         (progn
  66.           (setq
  67.             PS1 (cadr E1)  ; get point at which first 
  68.                            ; entity was selected
  69.             EL1 (entget (car E1))   ; association list for
  70.                                     ; first entity
  71.             EL2 (entget (car E2))   ; association list for
  72.                                     ; second entity
  73.             ET1 (cdr (assoc 0 EL1)) ; type of first entity
  74.             ET2 (cdr (assoc 0 EL2)) ; type of second entity
  75.           )
  76. ; swap data if arc/circle and line so that 
  77. ; line is first entity - this
  78. ; eliminates some code needed later
  79.           (if (and (/= ET1 "LINE") (= ET2 "LINE"))
  80.             (setq ET ET1 EL EL1 ET1 ET2 EL1 EL2 ET2 
  81.                   ET EL2 EL))
  82.           (cond
  83.             ((and (= ET1 "LINE") (= ET2 "LINE")) 
  84.                   (load "LL_INT"))
  85.             ((and (= ET1 "LINE") (or (= ET2 "ARC") 
  86.                   (= ET2 "CIRCLE")))
  87.               (load "LA_INT"))
  88.             ((and (or (= ET1 "ARC") (= ET1 "CIRCLE"))
  89.                (or (= ET2 "ARC") (= ET2 "CIRCLE"))) 
  90.                    (load "AA_INT"))
  91.             (T (setq P nil))
  92.           )
  93.         ) ;end progn
  94.         (prompt "No entity selected\n")
  95.       ) ;end E2 if
  96.     )  ;end progn
  97.     (prompt "No entity selected\n")
  98.   )
  99. ); end defun xint.lsp
  100.  
  101.